<template>
	<div>
		<van-nav-bar
			:title="title"
			:left-text="leftText"
			left-arrow
			@click-left="clickLeftText"
			@click-right="clickRightText">
			<template #right>
				<span class="rightColor">{{ rightText }}</span>
			</template>
		</van-nav-bar>
	</div>
</template>

<script setup lang="ts">
defineProps({
	title: {
		type: String,
		default: ''
	},
	leftText: {
		type: String,
		default: ''
	},
	rightText: {
		type: String,
		default: ''
	}
})
// 左侧文字点击事件
const clickLeftText = () => history.back()

// 右侧文字点击事件
interface EmitType {
	(e: 'toNamePath', params: string): void
}
const emit = defineEmits<EmitType>()
const clickRightText = () => {
	emit('toNamePath', '')
}
</script>

<style lang="scss" scoped>
.rightColor {
	color: var(--cp-primary) !important;
}
</style>
